<?php
require_once("../../class2.php");
require_once(HEADERF);
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

ramka("open"); if($user_rights["ADD"]===1 && USERNAME!='USERNAME') {
//--->  Common variables
$tempo= mysql_fetch_array(mysql_query("SELECT rows_all FROM admin_panel WHERE game_prefix = '$CMS_pref'"));
$allphrases= $tempo['rows_all']; 
if(!isset($alls)) $alls=0;

CMS_activitySave("listtranslations.php");

echo "<a href='filestable.php?game=$CMS_game' class='forumheader4' style='font-size:14px; margin-left:10px;'>НАЗАД</a>";
echo "<center class='forumheader4' style='margin-top:-20px; padding-bottom:14px;'><h1 style='border-bottom:0px;'>Преводи</h1></center>";
echo "<div class='forumheader4'>";
CMS_lastApprovedEcho();

$arr_pending = mysql_query("SELECT * FROM ".$translations_table." WHERE status like 'В процес на проверка...%' ORDER BY time DESC");
$arr_approved = mysql_query("SELECT * FROM ".$translations_table." WHERE status = 'Одобрен' ORDER BY time DESC");
$arr_unapproved = mysql_query("SELECT * FROM ".$translations_table." WHERE status = 'Неодобрен' ORDER BY time DESC");

echo <<< HTML
			<center style='margin-top:-18px;'>
			<table class="forumheader4" style="width: 500px;"><tr>
			<td class="cmsMenuDivider unselectable" WIDTH=10px><<</td>
			<td class="cmsMenuTab unselectable dictYELLOW" onclick=toggle('pending') WIDTH=33%><b>Чакащи</b></td>
			<td class="cmsMenuDivider unselectable" WIDTH=10px>||</td>
			<td class="cmsMenuTab unselectable dictRED" onclick=toggle('unapproved') WIDTH=33%><b>Неодобрени</b></td>
			<td class="cmsMenuDivider unselectable" WIDTH=10px>||</td>
			<td class="cmsMenuTab unselectable dictGREEN" onclick=toggle('approved') WIDTH=33%><b>Одобрени</b></td>
			<td class="cmsMenuDivider unselectable" WIDTH=10px>>></td>
			</tr></table>
			</center>
			<br>
HTML;
function print_sections($section, $div_name, $TDcolor, $DIVdisplay, $trans_type, $CMS_game) {
	echo <<<HTML
			<div id="$div_name" style="$DIVdisplay border: 0px solid #FFF; font-weight:italic;">
			<table cellpadding='5' style='width:100%;'>
			<tr class="forumheader" style="font-weight:normal;">
			<td><b>Име на файла</b></td>
			<td><b>Автор</b></td>
			<td><b>Реплики</b></td>
			<td><b>Дата</b></td>
			<td><b>Статус</b></td>
			<td><b>Пуснат преди</b></td>
			<td></td>
			</tr>
HTML;
	$a= 0;
	while($array = mysql_fetch_array($section)){
		if($a%2) {$class="cmsRow2";} else $class="cmsRow1";  
		echo "<tr class='forumheader3 textGREY' style='font-weight:normal;'>";
		$shortfilename= $array['file_name'];
		if(strlen($array['file_name']) > 30){
			$array['file_name'] = substr($array['file_name'], 0, 10)."...".substr($array['file_name'], -15);
		}
		echo "<td>".$array['file_name']."</td>";
		echo "<td class='textWHITE'>".$array['translator_name']."</td>";
		$translation = $array['translation'];
		$array_translation = explode("\n", $translation);
		$array_translation = clear_array($array_translation);
		$transrows= count($array_translation);
		global $alls;
		if ($div_name == "pending") $alls=$alls+$transrows;
		echo "<td><center>".$transrows."</center></td>";
		$trdate= months_inBG(date("j F : H:i", strtotime($array['time'])));
		echo "<td>".$trdate."</td>";
		$status = $array['status'];
		echo "<td class='text$TDcolor'>".$status."</td>";
		$time = time()-strtotime($array['time']);
		if($time < 60){
			echo "<td>".$time." секунди</td>";
		}
		elseif($time < 3600 and $time >= 60){
			echo "<td>".floor(($time)/60)." минути</td>";
		}
		elseif($time < 86400 and $time >= 3600){
			echo "<td>".floor(($time)/3600)." часа</td>";
		}
		elseif($time < 31536000 and $time >= 86400){
			echo "<td>".floor(($time)/86400)." дни</td>";
		}
		else{
			echo "<td>".floor(($time)/31536000)." години</td>";
		}
		echo "<td><a href='viewtext.php?game=".$CMS_game."&name=".$shortfilename."&page=".$array['page']."&go=pending#".$array['id']."' target='_blank'>ОТИДИ</a></td>";
		echo "</tr>";
		$a++;
	}
	if ($a===0) { echo "</table><div class='forumheader2 textGREY' style='font-weight:normal;'><center>Не бяха намерени <span class='text$TDcolor'>$trans_type</span> преводи.</center></div><div class='forumheader'></div>"; }
	else echo "<tr class='forumheader'><td><td><td><td><td><td><td></td></td></td></td></td></td></td></tr></table>";
	echo "</div>";
}

echo "<div style='margin-top: -14px;'><center>Чакат одобрение: <span id='all' title='all' class='textYELLOW'></span> (~<span id='percent' title='percent' class='textYELLOW'></span>)</center></div><br></div>";
print_sections($arr_pending, "pending", "YELLOW", "", "чакащи", $CMS_game);
$percent= number_format(round(($alls*100)/$allphrases, 2), 2, ',', ' ');
echo "<script type='text/javascript'> autoInsert('all', '$alls'); autoInsert('percent', '$percent%');</script>";
print_sections($arr_unapproved, "unapproved", "RED", "display: none;", "неодобрени", $CMS_game);
print_sections($arr_approved, "approved", "GREEN", "display: none;", "одобрени", $CMS_game);



} else echo"<div class='forumheader'>Нямате право да разглеждате този ресурс.</div>"; ramka("close");

require_once(FOOTERF);
?>